﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ThereAreNoIrreplaceblePeople.Models
{
    public class UserModel
    {
        static Database1Entities3 db = new Database1Entities3();

        public static List<Subject> GetSubjects(long userID)
        {
            var subjectsIds = db.CourseUser.Where(a => a.UserID == userID);
            List<Subject> subjects = new List<Subject>();

            foreach (CourseUser l in subjectsIds)
            {
                subjects.Add(db.Subject.FirstOrDefault(a => a.CourseCode == l.CourseCode));
            }

            return subjects;
        }
    }
}